#include "./circuit.hh"

#include <format>
#include <stdexcept>
// #include <print>

namespace ycspice::preprocess {

    Circuit::Circuit(std::string name) :
        _name{name} {}

    auto Circuit::add_port(std::string port_name) -> void {
        this->_ports.emplace_back(std::move(port_name), this->_ports.size());
    }

    auto Circuit::add_ports(std::span<std::string> port_names) -> void {
        for (auto& port : port_names) {
            this->add_port(std::move(port));
        }
    }

    auto Circuit::check_net_size(std::span<std::string> nets) const -> void {
        if (this->_ports.size() != nets.size()) {
            for (auto& _ : this->_ports) {
                // std::println("{}", n.name());
            }

            for (auto& _ : nets) {
                // std::println("{}", n);
            }

            throw std::runtime_error{
                std::format("Port size '{}' unmatch with net size '{}'", this->_ports.size(), nets.size())
            };
        }
    }

}